/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package bsc.ejb.entity;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author memozac
 */
@Entity
public class Milestone extends Task implements Serializable {
    private static final long serialVersionUID = 1L;
    
    @Temporal(value = TemporalType.DATE)
    private Date beginDate;

    @Temporal(value = TemporalType.DATE)
    private Date endDate;

    @ManyToMany(targetEntity=Tracer.class)
    @JoinTable(name="MilestoneTracer",
    joinColumns=@JoinColumn(name="idTask"),
    inverseJoinColumns=@JoinColumn(name="idTracer"))
    private Collection<Tracer> tracers;

    public Date getBeginDate() {
        return beginDate;
    }

    public void setBeginDate(Date beginDate) {
        this.beginDate = beginDate;
    }

    public Date getEndDate() {
        return endDate;
    }

    public void setEndDate(Date endDate) {
        this.endDate = endDate;
    }

    public Collection<Tracer> getTracers() {
        return tracers;
    }

    public void setTracers(Collection<Tracer> tracers) {
        this.tracers = tracers;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idTask != null ? idTask.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        if (!(object instanceof Milestone)) {
            return false;
        }
        Milestone other = (Milestone) object;
        if ((this.idTask == null && other.idTask != null) || (this.idTask != null && !this.idTask.equals(other.idTask))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "bsc.ejb.entity.Milestone[id=" + idTask + "]";
    }
}//ends of class
